﻿using ITXHWEB.Models;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Web.Mvc;
using WPFExcelReport;
using WPFExcelReport.Helpers;
using ITXHWEB.Infrastructure;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ITXHWEB.Controllers
{
    public partial class WBFKOPFController : ITXController
    {
        [ChildActionOnly]
        public ActionResult PWB18(string returnUrl)
        {
            ModelState.Clear();
            if (!MABF.CWBB.IsERKReady)
            {
                NEWWBFK();
            }
            ViewBag.ReturnUrl = returnUrl;
            return PartialView(MABF.CWBB.CERK);
        }
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult PWB18(WBFKOPFModel model, string returnUrl)
        {

            try
            {

                MWB.INFO = "";
            }
            catch (Exception ex)
            {
                //VKPAUF = ex.Message;
                Tracer.Error(ex.StackTrace, ex);
            }
            return RedirectToAction(MAPP, MAPP);
        }

        public void NEWWBFK()
        {
            WBFKOPFModel m;
            Helper.GetSTime(ref date, ref time, ref stime);
            MABF.CWBB.ERVER++;
            PM["RWKRS"] = MABF.CWBB.RWKRS;
            PM["RWLFD"] = MABF.CWBB.RWLFD;
            PM["RWPOS"] = MABF.CWBB.RWPOS;
            PM["ERVER"] = MABF.CWBB.ERVER;
            PM["USER"] = CUSER;
            PM["DATE"] = date;
            m = new WBFKOPFModel();
            m.ERRORS = new List<WBFEHLModel>();
            m.ERVER = MABF.CWBB.ERVER.ToString();
            m.dwMaster = VHP.VWBFK.NEWWBFK(PM);
            MABF.CWBB.CERK = m;
            MABF.CWBB.IsERKReady = true;
            MABF.IsERKReady = MABF.CWBB.IsERKReady;
        }
    }
}
